function [] = importTouristTripsMatrix2Matlab(region2regionFile, withinOriginRegionWeightsFile, withinDestinationRegionWeightsFile, outputFolder)
	
	% Add paths
	addpath('../code/general_funcs');
	
	% Read region-region weights
	[regionWeights, headerIds1] = makeArrayFromCSV(region2regionFile, 2);
	regIds1 = headerIds1{1};
	regIds1b = headerIds1{2};
	clear headerIds1;
		% regionWeights is NumRegions (Origin) x NumRegions (Destination)
	
	% Read region within-origin-region entity weights
	[withinOriginRegionWeights, headerIds2] = makeArrayFromCSV(withinOriginRegionWeightsFile, 2, {'char', 'double', 'double'});
	geoLabels1 = headerIds2{1};
	regIds2 = headerIds2{2};
	clear headerIds2;
		% withinOriginRegionWeights is NumEntities (Origin) x NumRegions (Origin)
	
	% Read region within-destination-region entity weights
	[withinDestinationRegionWeights, headerIds3] = makeArrayFromCSV(withinDestinationRegionWeightsFile, 2, {'char', 'double', 'double'});
	geoLabels2 = headerIds3{1};
	regIds3    = headerIds3{2};
	clear headerIds3;
		% withinDestinationRegionWeights is NumEntities (Destination) x NumRegions (Destination)
	
	% Check consistency of region and entity labels
	if ~isequal(geoLabels1, geoLabels2)
		error('Inconsistent geo labels');
	end
	if ~isequal(regIds1, regIds1b) ||  ~isequal(regIds1, regIds2) ||  ~isequal(regIds1, regIds3)
		error('Inconsistent region ids');
	end
	geoLabels = geoLabels1;
	regIds = regIds1;
	clear regIds1 regIds1b regIds2 regIds3;
	clear geoLabels1 geoLabels2;
	
	% Make the within-region weights sum to one (normalize the within-region weights)
	withinOriginRegionWeights		= withinOriginRegionWeights./sum(withinOriginRegionWeights,1);
	withinDestinationRegionWeights	= withinDestinationRegionWeights./sum(withinDestinationRegionWeights,1);
	
	% Compute entity-to-entity flows, under assumptions of within-region and within-destination weights
	flows = withinOriginRegionWeights * regionWeights * withinDestinationRegionWeights'; % NumEntities (Origin) x NumEntities (Destination)
	
	% Compute posterior probabilities conditional on origin/destination
	flows_condOrigin      = rowNormalize(flows); % NumEntities (Origin) x NumEntities (Destination)
	flows_condDestination = rowNormalize(flows'); % NumEntities (Destination) x NumEntities (Origin)
	
	%%% Make matrices sparse if that brings a gain
	if mean(flows(:) >0 ) < 0.3
		flows                 = sparse(flows);
		flows_condOrigin      = sparse(flows_condOrigin);
		flows_condDestination = sparse(flows_condDestination);
	end
	
	%%% Save unnormalized and normalized matrices to output files
	% flows
	W = flows;
	weightMatrixName = 'Weight_TouristTrip';
	outputFile = sprintf('%s/%s.mat', outputFolder, weightMatrixName);
	save(outputFile, 'W', 'weightMatrixName', '-v7.3');
	
	% flows_condOrigin
	W = flows_condOrigin;
	weightMatrixName = 'Weight_TouristTripCondOrigin';
	outputFile = sprintf('%s/%s.mat', outputFolder, weightMatrixName);
	save(outputFile, 'W', 'weightMatrixName', '-v7.3');
	
	% flows_condDestination
	W = flows_condDestination;
	weightMatrixName = 'Weight_TouristTripCondDestination';
	outputFile = sprintf('%s/%s.mat', outputFolder, weightMatrixName);
	save(outputFile, 'W', 'weightMatrixName', '-v7.3');
end
